home *** CD-ROM | disk | FTP | other *** search
/ PC Advisor 2007 June / PC Advisor 2007 June.iso / FULL / OPENOFFICE / openoffice.exe / openofficeorg2.cab / ooo2wordml_field.xsl < prev    next >
Extensible Markup Language  |  2005-09-08  |  42KB  |  742 lines

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--
  3.  
  4.     OpenOffice.org - a multi-platform office productivity suite
  5.  
  6.     $RCSfile: ooo2wordml_field.xsl,v $
  7.  
  8.     $Revision: 1.8 $
  9.  
  10.     last change: $Author: rt $ $Date: 2005/09/08 22:06:14 $
  11.  
  12.     The Contents of this file are made available subject to
  13.     the terms of GNU Lesser General Public License Version 2.1.
  14.  
  15.  
  16.       GNU Lesser General Public License Version 2.1
  17.       =============================================
  18.       Copyright 2005 by Sun Microsystems, Inc.
  19.       901 San Antonio Road, Palo Alto, CA 94303, USA
  20.  
  21.       This library is free software; you can redistribute it and/or
  22.       modify it under the terms of the GNU Lesser General Public
  23.       License version 2.1, as published by the Free Software Foundation.
  24.  
  25.       This library is distributed in the hope that it will be useful,
  26.       but WITHOUT ANY WARRANTY; without even the implied warranty of
  27.       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  28.       Lesser General Public License for more details.
  29.  
  30.       You should have received a copy of the GNU Lesser General Public
  31.       License along with this library; if not, write to the Free Software
  32.       Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  33.       MA  02111-1307  USA
  34.  
  35. -->
  36. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:w="http://schemas.microsoft.com/office/word/2003/wordml" xmlns:wx="http://schemas.microsoft.com/office/word/2003/auxHint" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:aml="http://schemas.microsoft.com/aml/2001/core" xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:w10="urn:schemas-microsoft-com:office:word" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0" xmlns:ooo="http://openoffice.org/2004/office" xmlns:ooow="http://openoffice.org/2004/writer" xmlns:oooc="http://openoffice.org/2004/calc" xmlns:dom="http://www.w3.org/2001/xml-events" exclude-result-prefixes="office table style text draw svg   dc config xlink meta oooc dom ooo chart math dr3d form script ooow draw">
  37.     <!-- the following are common used  fields -->
  38.     <xsl:template match="text:page-number | text:page-count | text:subject | text:initial-creator |  text:title  | text:date
  39.      | text:time | text:page-variable-get | text:author-name | text:author-initials | text:file-name  | text:sender-company
  40.      | text:sender-initials | text:sender-phone-work | text:word-count  | text:paragraph-count | text:character-count
  41.      | text:description | text:creation-time | text:creation-date | text:editing-cycles | text:editing-duration
  42.      | text:keywords | text:print-time | text:print-date | text:creator | text:modification-time | text:modification-date
  43.      | text:user-defined  | text:variable-get | text:user-field-get | text:sequence | text:database-name ">
  44.         <w:fldSimple>
  45.             <xsl:variable name="attribute_value1">
  46.                 <xsl:choose>
  47.                     <xsl:when test="name() = 'text:page-number' or name() = 'text:page-variable-get' ">
  48.                         <xsl:text> PAGE  </xsl:text>
  49.                     </xsl:when>
  50.                     <xsl:when test="name() = 'text:page-count' ">
  51.                         <xsl:text> NUMPAGES </xsl:text>
  52.                     </xsl:when>
  53.                     <xsl:when test=" name() = 'text:subject' ">
  54.                         <xsl:text> SUBJECT  </xsl:text>
  55.                     </xsl:when>
  56.                     <xsl:when test="name() = 'text:initial-creator' ">
  57.                         <xsl:text> AUTHOR  </xsl:text>
  58.                     </xsl:when>
  59.                     <xsl:when test=" name() = 'text:title' ">
  60.                         <xsl:text> TITLE    </xsl:text>
  61.                     </xsl:when>
  62.                     <xsl:when test="name() = 'text:date' ">
  63.                         <xsl:text> DATE   </xsl:text>
  64.                         <!-- ATM, this template just return null date format, it might be  developed in the future -->
  65.                         <xsl:call-template name="field_get_date_format">
  66.                             <xsl:with-param name="field_date_stylename" select="@style:data-style-name"/>
  67.                             <xsl:with-param name="field_date_value" select="@text:date-value"/>
  68.                         </xsl:call-template>
  69.                     </xsl:when>
  70.                     <xsl:when test=" name() = 'text:time' ">
  71.                         <xsl:text> TIME   </xsl:text>
  72.                         <!-- ATM, this template just return null time format, it might be  developed in the future -->
  73.                         <xsl:call-template name="field_get_time_format">
  74.                             <xsl:with-param name="field_time_stylename" select="@style:data-style-name"/>
  75.                             <xsl:with-param name="field_time_value" select="@text:time-value"/>
  76.                         </xsl:call-template>
  77.                     </xsl:when>
  78.                     <xsl:when test="name() = 'text:author-name' ">
  79.                         <xsl:text> AUTHOR   </xsl:text>
  80.                     </xsl:when>
  81.                     <xsl:when test="name() = 'text:author-initials' ">
  82.                         <xsl:text> USERINITIALS </xsl:text>
  83.                     </xsl:when>
  84.                     <xsl:when test="name() = 'text:file-name' ">
  85.                         <xsl:choose>
  86.                             <xsl:when test="@text:display='name-and-extension' or  @text:display='name' ">
  87.                                 <xsl:text> FILENAME   </xsl:text>
  88.                             </xsl:when>
  89.                             <xsl:when test=" @text:display='full' or @text:display='path' ">
  90.                                 <xsl:text>FILENAME    \p </xsl:text>
  91.                             </xsl:when>
  92.                         </xsl:choose>
  93.                     </xsl:when>
  94.                     <xsl:when test=" name() = 'text:sender-company' ">
  95.                         <xsl:text> DOCPROPERTY  Company  </xsl:text>
  96.                     </xsl:when>
  97.                     <xsl:when test="name() = 'text:sender-initials' ">
  98.                         <xsl:text> USERINITIALS  </xsl:text>
  99.                     </xsl:when>
  100.                     <xsl:when test="name() = 'text:sender-phone-work' ">
  101.                         <xsl:text> DOCPROPERTY  "Telephone number" </xsl:text>
  102.                     </xsl:when>
  103.                     <xsl:when test="name() = 'text:word-count' ">
  104.                         <xsl:text> DOCPROPERTY  Words </xsl:text>
  105.                     </xsl:when>
  106.                     <xsl:when test="name() = 'text:paragraph-count'  ">
  107.                         <xsl:text> DOCPROPERTY  Paragraphs </xsl:text>
  108.                     </xsl:when>
  109.                     <xsl:when test="name() = 'text:character-count' ">
  110.                         <xsl:text> DOCPROPERTY  CharactersWithSpaces </xsl:text>
  111.                     </xsl:when>
  112.                     <xsl:when test="name() = 'text:description' ">
  113.                         <xsl:text> COMMENTS  </xsl:text>
  114.                     </xsl:when>
  115.                     <xsl:when test="name() = 'text:creation-time' ">
  116.                         <xsl:text> DOCPROPERTY  CreateTime </xsl:text>
  117.                         <!-- ATM, this template just return null time format, it might be  developed in the future -->
  118.                         <xsl:call-template name="field_get_time_format">
  119.                             <xsl:with-param name="field_time_stylename" select="@style:data-style-name"/>
  120.                             <xsl:with-param name="field_time_value" select="@text:time-value"/>
  121.                         </xsl:call-template>
  122.                     </xsl:when>
  123.                     <xsl:when test=" name()= 'text:creation-date' ">
  124.                         <xsl:text> CREATEDATE </xsl:text>
  125.                         <!-- ATM, this template just return null date format, it might be  developed in the future -->
  126.                         <xsl:call-template name="field_get_date_format">
  127.                             <xsl:with-param name="field_date_stylename" select="@style:data-style-name"/>
  128.                             <xsl:with-param name="field_date_value" select="@text:date-value"/>
  129.                         </xsl:call-template>
  130.                     </xsl:when>
  131.                     <xsl:when test=" name() = 'text:editing-cycles' ">
  132.                         <xsl:text> REVNUM \* Arabic </xsl:text>
  133.                     </xsl:when>
  134.                     <xsl:when test=" name() = 'text:editing-duration' ">
  135.                         <xsl:text> EDITTIME </xsl:text>
  136.                     </xsl:when>
  137.                     <xsl:when test=" name() = 'text:keywords' ">
  138.                         <xsl:text> KEYWORDS </xsl:text>
  139.                     </xsl:when>
  140.                     <xsl:when test=" name() = 'text:print-time' ">
  141.                         <xsl:text>DOCPROPERTY  LastPrinted  </xsl:text>
  142.                         <!-- ATM, this template just return null time format, it might be  developed in the future -->
  143.                         <xsl:call-template name="field_get_time_format">
  144.                             <xsl:with-param name="field_time_stylename" select="@style:data-style-name"/>
  145.                             <xsl:with-param name="field_time_value" select="@text:time-value"/>
  146.                         </xsl:call-template>
  147.                     </xsl:when>
  148.                     <xsl:when test=" name() = 'text:print-date' ">
  149.                         <xsl:text>DOCPROPERTY  LastPrinted </xsl:text>
  150.                         <!-- ATM, this template just return null date format, it might be  developed in the future -->
  151.                         <xsl:call-template name="field_get_date_format">
  152.                             <xsl:with-param name="field_date_stylename" select="@style:data-style-name"/>
  153.                             <xsl:with-param name="field_date_value" select="@text:date-value"/>
  154.                         </xsl:call-template>
  155.                     </xsl:when>
  156.                     <xsl:when test=" name() = 'text:creator' ">
  157.                         <xsl:text> LASTSAVEDBY  </xsl:text>
  158.                     </xsl:when>
  159.                     <xsl:when test=" name() = 'text:modification-time' ">
  160.                         <xsl:text> DOCPROPERTY  LastSavedTime </xsl:text>
  161.                         <!-- ATM, this template just return null time format, it might be  developed in the future -->
  162.                         <xsl:call-template name="field_get_time_format">
  163.                             <xsl:with-param name="field_time_stylename" select="@style:data-style-name"/>
  164.                             <xsl:with-param name="field_time_value" select="@text:time-value"/>
  165.                         </xsl:call-template>
  166.                     </xsl:when>
  167.                     <xsl:when test=" name() = 'text:modification-date' ">
  168.                         <xsl:text> SAVEDATE  </xsl:text>
  169.                         <!-- ATM, this template just return null date format, it might be  developed in the future -->
  170.                         <xsl:call-template name="field_get_date_format">
  171.                             <xsl:with-param name="field_date_stylename" select="@style:data-style-name"/>
  172.                             <xsl:with-param name="field_date_value" select="@text:date-value"/>
  173.                         </xsl:call-template>
  174.                     </xsl:when>
  175.                     <xsl:when test=" name() = 'text:user-defined' ">
  176.                         <xsl:text>  DOCPROPERTY </xsl:text>
  177.                         <xsl:text>"</xsl:text>
  178.                         <xsl:value-of select="translate(string(@text:name), ' ', '')"/>
  179.                         <xsl:text>"</xsl:text>
  180.                     </xsl:when>
  181.                     <xsl:when test="name() = 'text:variable-get' or name() = 'text:user-field-get' ">
  182.                         <xsl:value-of select="concat ('DOCVARIABLE ', @text:name)"/>
  183.                     </xsl:when>
  184.                     <xsl:when test=" name() = 'text:sequence' ">
  185.                         <xsl:value-of select="concat(' SEQ  "',@text:name, '"') "/>
  186.                     </xsl:when>
  187.                     <xsl:when test="name() = 'text:database-name' ">
  188.                         <xsl:value-of select="concat (' DATABASE ', @text:database-name, '.' , @text:table-name)"/>
  189.                     </xsl:when>
  190.                 </xsl:choose>
  191.                 <!-- Get number style format for number fields -->
  192.                 <xsl:if test="@style:num-format">
  193.                     <xsl:call-template name="field_get_number_format">
  194.                         <xsl:with-param name="field_number_format_style" select="@style:num-format"/>
  195.                     </xsl:call-template>
  196.                 </xsl:if>
  197.                 <xsl:text>  \* MERGEFORMAT </xsl:text>
  198.             </xsl:variable>
  199.             <xsl:attribute name="w:instr">
  200.                 <xsl:value-of select="$attribute_value1"/>
  201.             </xsl:attribute>
  202.             <w:r>
  203.                 <w:rPr>
  204.                     <xsl:choose>
  205.                         <xsl:when test="@style:num-format = 'Ω░Ç, δéÿ, δïñ, ...' or @style:num-format ='∞¥╝, ∞¥┤, ∞é╝, ...' or @style:num-format ='πä▒, πä┤, πä╖, ...' ">
  206.                             <w:rFonts w:fareast="Batang" w:hint="fareast"/>
  207.                             <!--wx:font wx:val="Batang"/ -->
  208.                             <w:lang w:fareast="KO"/>
  209.                         </xsl:when>
  210.                         <xsl:when test="@style:num-format = 'πéó, πéñ, πéª, ...' or @style:num-format = '∩╜▒, ∩╜▓, ∩╜│, ...' or @style:num-format = 'πéñ, πâ¡, πâÅ, ...' or @style:num-format = '∩╜▓, ∩╛¢, ∩╛è, ...' or @style:num-format ='σú▒, σ╝É, σÅé, ...' ">
  211.                             <w:rFonts w:fareast="MS Mincho" w:hint="fareast"/>
  212.                             <!--wx:font wx:val="MS Mincho"/ -->
  213.                             <w:lang w:fareast="JA"/>
  214.                         </xsl:when>
  215.                         <xsl:when test=" @style:num-format  ='σú╣,     Φ▓│, σÅâ, ...' or @style:num-format  ='σú╣, Φ▓│, σÅâ, ...' or @style:num-format  ='σú╣, Φ┤░,     σÅü, ...'or  @style:num-format  = 'Σ╕Ç, Σ║î, Σ╕ë, ...' ">
  216.                             <w:rFonts w:hint="fareast"/>
  217.                             <!--wx:font wx:val="σ«ïΣ╜ô"/ -->
  218.                         </xsl:when>
  219.                     </xsl:choose>
  220.                     <w:noProof/>
  221.                 </w:rPr>
  222.                 <w:t>
  223.                     <xsl:value-of select="."/>
  224.                 </w:t>
  225.             </w:r>
  226.         </w:fldSimple>
  227.     </xsl:template>
  228.     <xsl:template name="field_get_number_format">
  229.         <!-- this template get the various of number formats for number type field-->
  230.         <xsl:param name="field_number_format_style"/>
  231.         <xsl:choose>
  232.             <xsl:when test=" $field_number_format_style = '∩╝æ, ∩╝Æ, ∩╝ô, ...' or $field_number_format_style = '1'      ">
  233.                 <xsl:text>  \* Arabic </xsl:text>
  234.             </xsl:when>
  235.             <xsl:when test="$field_number_format_style = 'Γæá, Γæí, Γæó, ...' ">
  236.                 <xsl:text> \* CircleNum </xsl:text>
  237.             </xsl:when>
  238.             <xsl:when test="$field_number_format_style = 'i' ">
  239.                 <xsl:text>  \* roman  </xsl:text>
  240.             </xsl:when>
  241.             <xsl:when test="$field_number_format_style = 'I' ">
  242.                 <xsl:text>  \* ROMAN </xsl:text>
  243.             </xsl:when>
  244.             <xsl:when test="$field_number_format_style = 'Σ╕Ç, Σ║î, Σ╕ë, ...'">
  245.                 <xsl:text>  \* CHINESENUM3  </xsl:text>
  246.             </xsl:when>
  247.             <xsl:when test="  $field_number_format_style ='σú╣,     Φ▓│, σÅâ, ...' or $field_number_format_style ='σú╣, Φ▓│, σÅâ, ...' or
  248. $field_number_format_style ='σú╣, Φ┤░, σÅü, ...' ">
  249.                 <xsl:text>  \* CHINESENUM2  </xsl:text>
  250.             </xsl:when>
  251.             <xsl:when test="$field_number_format_style = 'σú▒, σ╝É, σÅé, ...' ">
  252.                 <xsl:text>  \* DBNUM3  </xsl:text>
  253.             </xsl:when>
  254.             <xsl:when test="$field_number_format_style = 'σ¡É, Σ╕æ, σ»à, ...' ">
  255.                 <xsl:text>  \* ZODIAC2 </xsl:text>
  256.             </xsl:when>
  257.             <xsl:when test=" $field_number_format_style ='τö▓, Σ╣Ö, Σ╕Ö, ...' ">
  258.                 <xsl:text>  \* ZODIAC1 </xsl:text>
  259.             </xsl:when>
  260.             <xsl:when test="$field_number_format_style = 'πéñ, πâ¡, πâÅ, ...' or $field_number_format_style = '∩╜▓, ∩╛¢, ∩╛è, ...' ">
  261.                 <xsl:text> \* Iroha </xsl:text>
  262.             </xsl:when>
  263.             <xsl:when test="$field_number_format_style ='∩╜▒, ∩╜▓, ∩╜│, ...' or $field_number_format_style ='πéó, πéñ, πéª, ...' ">
  264.                 <xsl:text> \* Aiueo </xsl:text>
  265.             </xsl:when>
  266.             <xsl:when test="$field_number_format_style = '∞¥╝, ∞¥┤, ∞é╝, ...' ">
  267.                 <xsl:text> \* DBNUM1 </xsl:text>
  268.             </xsl:when>
  269.             <xsl:when test="$field_number_format_style ='πä▒, πä┤, πä╖, ...' or $field_number_format_style = 'πëá, πëí, πëó, ...' ">
  270.                 <xsl:text> \* Chosung  </xsl:text>
  271.             </xsl:when>
  272.             <xsl:when test="$field_number_format_style = 'Ω░Ç, δéÿ, δïñ, ...' or $field_number_format_style = 'πë«, πë», πë░, ...' ">
  273.                 <xsl:text>  \* Ganada </xsl:text>
  274.             </xsl:when>
  275.             <xsl:when test="$field_number_format_style = 'πéó, πéñ, πéª, ...' or $field_number_format_style = '∩╜▒, ∩╜▓, ∩╜│, ...' ">
  276.                 <xsl:text>  \* Aiueo </xsl:text>
  277.             </xsl:when>
  278.             <xsl:when test="$field_number_format_style ='a' ">
  279.                 <xsl:text>  \* alphabetic </xsl:text>
  280.             </xsl:when>
  281.             <xsl:when test="$field_number_format_style ='A' ">
  282.                 <xsl:text>  \* ALPHABETIC </xsl:text>
  283.             </xsl:when>
  284.             <xsl:when test="$field_number_format_style = '╫É, ╫æ, ╫Æ, ...' ">
  285.                 <xsl:text>  \* hebrew2  </xsl:text>
  286.             </xsl:when>
  287.             <xsl:when test="$field_number_format_style = '╪ú, ╪¿, ╪¬, ...' ">
  288.                 <xsl:text>  \* ArabicAlpha </xsl:text>
  289.             </xsl:when>
  290.             <xsl:when test="$field_number_format_style = 'α╕ü, α╕é, α╕â, ...' ">
  291.                 <xsl:text>  \* ThaiLetter </xsl:text>
  292.             </xsl:when>
  293.             <xsl:otherwise>
  294.                 <xsl:text> </xsl:text>
  295.             </xsl:otherwise>
  296.         </xsl:choose>
  297.     </xsl:template>
  298.     <xsl:template name="field_get_date_format">
  299.         <xsl:param name="field_date_stylename"/>
  300.         <xsl:param name="field_date_value"/>
  301.         <!-- this template retun null date format ATM-->
  302.         <xsl:text/>
  303.     </xsl:template>
  304.     <xsl:template name="field_get_time_format">
  305.         <xsl:param name="field_time_stylename"/>
  306.         <xsl:param name="field_time_value"/>
  307.         <!-- this template retun null date format ATM-->
  308.         <xsl:text/>
  309.     </xsl:template>
  310.     <xsl:template match="text:template-name">
  311.         <xsl:choose>
  312.             <xsl:when test="@text:display='title' or @text:display= 'area' ">
  313.                 <!-- directly export the content -->
  314.                 <w:r>
  315.                     <w:rPr>
  316.                         <w:noProof/>
  317.                     </w:rPr>
  318.                     <w:t>
  319.                         <xsl:value-of select="."/>
  320.                     </w:t>
  321.                 </w:r>
  322.             </xsl:when>
  323.             <xsl:otherwise>
  324.                 <w:fldSimple>
  325.                     <xsl:variable name="template_attribute_value">
  326.                         <xsl:choose>
  327.                             <xsl:when test="@text:display='name-and-extension' or          @text:display= 'name' ">
  328.                                 <xsl:text> TEMPLATE </xsl:text>
  329.                             </xsl:when>
  330.                             <xsl:when test=" @text:display='full' or @text:display='path' ">
  331.                                 <xsl:text>TEMPLATE  \p </xsl:text>
  332.                             </xsl:when>
  333.                         </xsl:choose>
  334.                         <xsl:text>\* MERGEFORMAT </xsl:text>
  335.                     </xsl:variable>
  336.                     <xsl:attribute name="w:instr">
  337.                         <xsl:value-of select="$template_attribute_value"/>
  338.                     </xsl:attribute>
  339.                     <w:r>
  340.                         <w:rPr>
  341.                             <w:noProof/>
  342.                         </w:rPr>
  343.                         <w:t>
  344.                             <xsl:value-of select="."/>
  345.                         </w:t>
  346.                     </w:r>
  347.                 </w:fldSimple>
  348.             </xsl:otherwise>
  349.         </xsl:choose>
  350.     </xsl:template>
  351.     <xsl:template match="text:text-input | text:variable-input | text:user-field-input">
  352.         <w:fldSimple>
  353.             <xsl:variable name="text-input-attribute">
  354.                 <xsl:text>FILLIN  </xsl:text>
  355.                 <xsl:if test="@text:description">
  356.                     <xsl:value-of select="@text:description"/>
  357.                 </xsl:if>
  358.                 <xsl:text> \* MERGEFORMAT</xsl:text>
  359.             </xsl:variable>
  360.             <xsl:attribute name="w:instr">
  361.                 <xsl:value-of select="$text-input-attribute"/>
  362.             </xsl:attribute>
  363.             <w:r>
  364.                 <w:rPr>
  365.                     <w:noProof/>
  366.                 </w:rPr>
  367.                 <xsl:call-template name="field_convert_linebreak">
  368.                     <xsl:with-param name="field_input_text" select="text()"/>
  369.                 </xsl:call-template>
  370.             </w:r>
  371.         </w:fldSimple>
  372.     </xsl:template>
  373.     <xsl:template name="field_convert_linebreak">
  374.         <!-- this template convert the linebreak (  and  ) in continous text to Ms word element<w:br/> -->
  375.         <xsl:param name="field_input_text"/>
  376.         <xsl:if test="not (contains($field_input_text,' '))">
  377.             <w:t>
  378.                 <xsl:value-of select="$field_input_text"/>
  379.             </w:t>
  380.         </xsl:if>
  381.         <xsl:if test="contains($field_input_text,' ')">
  382.             <w:t>
  383.                 <xsl:value-of select="translate(substring-before($field_input_text,' '),' ','')"/>
  384.             </w:t>
  385.             <w:br/>
  386.             <xsl:call-template name="field_convert_linebreak">
  387.                 <xsl:with-param name="field_input_text" select="substring-after($field_input_text,' ')"/>
  388.             </xsl:call-template>
  389.         </xsl:if>
  390.     </xsl:template>
  391.     <xsl:template name="field_declare">
  392.         <!-- this template export the field declaration to w:docpr -->
  393.         <xsl:param name="simple_field_variable_declares"/>
  394.         <xsl:param name="user_field_variable_declares"/>
  395.         <xsl:param name="field_sequence_declares"/>
  396.         <w:docVars>
  397.             <xsl:if test="$simple_field_variable_declares/text:variable-decl">
  398.                 <xsl:for-each select="$simple_field_variable_declares/text:variable-decl">
  399.                     <w:docVar w:name="{@text:name}" w:val="default value"/>
  400.                 </xsl:for-each>
  401.             </xsl:if>
  402.             <xsl:if test="$user_field_variable_declares/text:user-field-decl">
  403.                 <xsl:for-each select="$user_field_variable_declares/text:user-field-decl">
  404.                     <w:docVar w:name="{@text:name}" w:val="{@text:string-value}"/>
  405.                 </xsl:for-each>
  406.             </xsl:if>
  407.             <xsl:if test="$field_sequence_declares/text:sequence-decl">
  408.                 <!-- do nothing for sequence declares when exporting to MS word-->
  409.             </xsl:if>
  410.         </w:docVars>
  411.     </xsl:template>
  412.     <xsl:template match="text:reference-ref | text:bookmark-ref | text:footnote-ref
  413.                                 | text:endnote-ref ">
  414.         <!-- this template is for reference fields -->
  415.         <w:r>
  416.             <w:fldChar w:fldCharType="begin"/>
  417.         </w:r>
  418.         <xsl:variable name="complicate_field_instruction">
  419.             <xsl:choose>
  420.                 <xsl:when test=" name() = 'text:reference-ref'  ">
  421.                     <xsl:choose>
  422.                         <xsl:when test=" string(@text:reference-format) = 'page' ">
  423.                             <xsl:value-of select="concat(' PAGEREF ', @text:ref-name, '\h') "/>
  424.                         </xsl:when>
  425.                         <xsl:when test="string(@text:reference-format) = 'chapter' ">
  426.                             <xsl:value-of select="concat(' REF ',  @text:ref-name, '\n \h') "/>
  427.                         </xsl:when>
  428.                         <xsl:when test="string(@text:reference-format) = 'text' ">
  429.                             <xsl:value-of select="concat ( ' REF ' , @text:ref-name, ' \h') "/>
  430.                         </xsl:when>
  431.                         <xsl:when test="string(@text:reference-format) = 'direction' ">
  432.                             <xsl:value-of select="concat(' REF ', @text:ref-name, ' \p \h' ) "/>
  433.                         </xsl:when>
  434.                         <xsl:otherwise>
  435.                             <xsl:value-of select="concat ( ' PAGEREF ', @text:ref-name, '\h')"/>
  436.                         </xsl:otherwise>
  437.                     </xsl:choose>
  438.                 </xsl:when>
  439.                 <xsl:when test="name() = 'text:footnote-ref' or name() = 'text:endnote-ref' ">
  440.                     <xsl:choose>
  441.                         <xsl:when test=" string(@text:reference-format) = 'page' ">
  442.                             <xsl:value-of select="concat(' PAGEREF ', @text:ref-name, '\h') "/>
  443.                         </xsl:when>
  444.                         <xsl:when test="string(@text:reference-format) = 'chapter' ">
  445.                             <xsl:value-of select="concat(' REF ',  @text:ref-name, '\n  \h') "/>
  446.                         </xsl:when>
  447.                         <xsl:when test="string(@text:reference-format) = 'text' ">
  448.                             <xsl:value-of select="concat ( ' NOTEREF ' , @text:ref-name, ' \h') "/>
  449.                         </xsl:when>
  450.                         <xsl:when test="string(@text:reference-format) = 'direction' ">
  451.                             <xsl:value-of select="concat(' PAGEREF ', @text:ref-name, ' \p \h' ) "/>
  452.                         </xsl:when>
  453.                         <xsl:otherwise>
  454.                             <xsl:value-of select="concat ( ' PAGEREF ', @text:ref-name, '\h')"/>
  455.                         </xsl:otherwise>
  456.                     </xsl:choose>
  457.                 </xsl:when>
  458.                 <xsl:when test="name() = 'text:bookmark-ref' ">
  459.                     <xsl:choose>
  460.                         <xsl:when test=" string(@text:reference-format) = 'page' ">
  461.                             <xsl:value-of select="concat(' PAGEREF ', @text:ref-name, '\h') "/>
  462.                         </xsl:when>
  463.                         <xsl:when test="string(@text:reference-format) = 'chapter' ">
  464.                             <xsl:value-of select="concat(' PAGEREF ',  @text:ref-name, '  \h') "/>
  465.                         </xsl:when>
  466.                         <xsl:when test="string(@text:reference-format) = 'text' ">
  467.                             <xsl:value-of select="concat ( ' REF ' , @text:ref-name, ' \h') "/>
  468.                         </xsl:when>
  469.                         <xsl:when test="string(@text:reference-format) = 'direction' ">
  470.                             <xsl:value-of select="concat(' REF ', @text:ref-name, ' \p \h' ) "/>
  471.                         </xsl:when>
  472.                         <xsl:otherwise>
  473.                             <xsl:value-of select="concat ( ' PAGEREF ', @text:ref-name, '\h')"/>
  474.                         </xsl:otherwise>
  475.                     </xsl:choose>
  476.                 </xsl:when>
  477.             </xsl:choose>
  478.         </xsl:variable>
  479.         <!--start to combine the complicate field instruction -->
  480.         <w:r>
  481.             <w:instrText>
  482.                 <xsl:value-of select="$complicate_field_instruction"/>
  483.             </w:instrText>
  484.         </w:r>
  485.         <w:r>
  486.             <w:fldChar w:fldCharType="separate"/>
  487.         </w:r>
  488.         <w:r>
  489.             <w:rPr>
  490.                 <w:noProof/>
  491.             </w:rPr>
  492.             <w:t>
  493.                 <xsl:value-of select="."/>
  494.             </w:t>
  495.         </w:r>
  496.         <w:r>
  497.             <w:fldChar w:fldCharType="end"/>
  498.         </w:r>
  499.     </xsl:template>
  500.     <xsl:template match="text:chapter | text:sender-firstname | text:sender-lastname
  501.                                     | text:sender-street | text:sender-country | text:sender-postal-code
  502.                                     | text:sender-city | text:sender-title | text:sender-position
  503.                                     | text:sender-phone-private | text:sender-email | text:sender-fax
  504.                                     | text:sender-state-or-province | text:table-count | text:image-count
  505.                                     | text:object-count | text:printed-by | text:hidden-paragraph
  506.                                     | text:placeholder | text:drop-down | text:conditional-text
  507.                                     | text:variable-set | text:table-formula | text:database-display
  508.                                     | text:database-next | text:database-select | text:database-row-number
  509.                                     | text:sequence-ref | text:expression | text:sheet-name | text:dde-connection">
  510.         <!-- this template just export content of staroffice fields that do not have the corresponding fields in MS word  ATM -->
  511.         <w:r>
  512.             <w:rPr>
  513.                 <w:noProof/>
  514.             </w:rPr>
  515.             <w:t>
  516.                 <xsl:value-of select="."/>
  517.             </w:t>
  518.         </w:r>
  519.     </xsl:template>
  520.     <xsl:template match="text:execute-macro | text:variable-decls | text:variable-decl | text:user-field-decls | text:variable-decl | text:sequence-decls | text:sequence-decl | text:page-variable-set |  text:bibliography-mark | text:script | text:page-continuation ">
  521.         <!-- this template is to ignore matched elements when exporting writer to word -->
  522.     </xsl:template>
  523.     <xsl:template match="text:a ">
  524.         <xsl:call-template name="export_hyoerlink"/>
  525.     </xsl:template>
  526.     <xsl:template name="export_hyoerlink">
  527.         <!-- all params are useed by draw -->
  528.         <xsl:param name="TargetMeasure"/>
  529.         <xsl:param name="x-adjust"/>
  530.         <xsl:param name="y-adjust"/>
  531.         <xsl:param name="force-draw"/>
  532.         <!-- this template processes the hyperlink in writer -->
  533.         <xsl:variable name="hyperlink_filename">
  534.             <xsl:choose>
  535.                 <xsl:when test="contains(@xlink:href, '#')">
  536.                     <xsl:value-of select="substring-before(@xlink:href, '#')"/>
  537.                 </xsl:when>
  538.                 <xsl:otherwise>
  539.                     <xsl:value-of select="@xlink:href"/>
  540.                 </xsl:otherwise>
  541.             </xsl:choose>
  542.         </xsl:variable>
  543.         <xsl:variable name="hyperlink_bookmark">
  544.             <xsl:if test="contains(@xlink:href, '#')">
  545.                 <xsl:choose>
  546.                     <xsl:when test="contains(@xlink:href, '%7C')">
  547.                         <xsl:call-template name="translate_string">
  548.                             <xsl:with-param name="t_input_string" select="substring-before( substring-after(@xlink:href, '#'), '%7C')"/>
  549.                             <xsl:with-param name="t_pattern_string" select=" '%20' "/>
  550.                             <xsl:with-param name="t_substitute_string" select=" ' ' "/>
  551.                             <xsl:with-param name="t_output_string" select=" '' "/>
  552.                         </xsl:call-template>
  553.                     </xsl:when>
  554.                     <xsl:otherwise>
  555.                         <xsl:call-template name="translate_string">
  556.                             <xsl:with-param name="t_input_string" select="substring-after(@xlink:href, '#')"/>
  557.                             <xsl:with-param name="t_pattern_string" select=" '%20' "/>
  558.                             <xsl:with-param name="t_substitute_string" select=" ' ' "/>
  559.                             <xsl:with-param name="t_output_string" select=" '' "/>
  560.                         </xsl:call-template>
  561.                     </xsl:otherwise>
  562.                 </xsl:choose>
  563.             </xsl:if>
  564.         </xsl:variable>
  565.         <w:hlink>
  566.             <xsl:if test="@xlink:href">
  567.                 <xsl:attribute name="w:dest">
  568.                     <xsl:value-of select="$hyperlink_filename"/>
  569.                 </xsl:attribute>
  570.             </xsl:if>
  571.             <xsl:if test="contains(@xlink:href, '#')">
  572.                 <xsl:attribute name="w:bookmark">
  573.                     <xsl:value-of select="$hyperlink_bookmark"/>
  574.                 </xsl:attribute>
  575.             </xsl:if>
  576.             <xsl:if test="@office:target-frame-name">
  577.                 <xsl:attribute name="w:target">
  578.                     <xsl:value-of select="@office:target-frame-name"/>
  579.                 </xsl:attribute>
  580.             </xsl:if>
  581.             <xsl:if test="@office:name">
  582.                 <xsl:attribute name="w:screenTip">
  583.                     <xsl:value-of select="@office:name"/>
  584.                 </xsl:attribute>
  585.             </xsl:if>
  586.             <w:r>
  587.                 <w:rPr>
  588.                     <w:rStyle w:val="Hyperlink"/>
  589.                 </w:rPr>
  590.                 <!--apply inline-text-elements, many many many ...  -->
  591.                 <xsl:apply-templates select="text:a | text:span | text() | text:hidden-text
  592.             | text:line-break | text:tab-stop | text:s | text:page-number | text:page-count | text:subject
  593.             | text:initial-creator | text:title | text:date | text:time | text:author-name
  594.             | text:author-initials | text:chapter | text:file-name | text:sender-company
  595.             | text:sender-firstname | text:sender-lastname | text:sender-initials | text:sender-street
  596.             | text:sender-country | text:sender-postal-code | text:sender-city | text:sender-title
  597.             | text:sender-position | text:sender-phone-private | text:sender-phone-work
  598.             | text:sender-email | text:sender-fax | text:sender-state-or-province | text:word-count
  599.             | text:paragraph-count | text:character-count | text:table-count | text:image-count
  600.             | text:object-count | text:template-name | text:description | text:creation-time
  601.             | text:creation-date | text:editing-cycles | text:editing-duration | text:keywords
  602.             | text:print-time | text:print-date | text:creator | text:modification-time
  603.             | text:modification-date | text:user-defined | text:printed-by | text:hidden-paragraph
  604.             | text:placeholder | text:drop-down | text:conditional-text  | text:text-input
  605.             | text:execute-macro | text:variable-set | text:variable-input
  606.             | text:user-field-input | text:variable-get | text:user-field-get | text:sequence
  607.             | text:page-variable-set | text:page-variable-get | text:table-formula
  608.             | text:database-display | text:database-next| text:database-select
  609.             | text:database-row-number | text:database-name | text:reference-ref
  610.             | text:bookmark-ref | text:footnote-ref  | text:endnote-ref | text:sequence-ref
  611.             | text:expression | text:measure | text:dde-connection | text:sheet-name
  612.             | text:bibliography-mark | text:script | text:page-continuation | office:annotation
  613.             | draw:*">
  614.                     <xsl:with-param name="TargetMeasure" select="$TargetMeasure"/>
  615.                     <xsl:with-param name="x-adjust" select="$x-adjust"/>
  616.                     <xsl:with-param name="y-adjust" select="$y-adjust"/>
  617.                     <xsl:with-param name="force-draw" select="$force-draw"/>
  618.                 </xsl:apply-templates>
  619.             </w:r>
  620.         </w:hlink>
  621.     </xsl:template>
  622.     <xsl:template name="translate_string">
  623.         <!-- this template is to replace  the substring  matched t_pattern_string  in t_t_input_string with t_substitute_string  G.Y.-->
  624.         <xsl:param name="t_input_string"/>
  625.         <xsl:param name="t_pattern_string"/>
  626.         <xsl:param name="t_substitute_string"/>
  627.         <xsl:param name="t_output_string"/>
  628.         <xsl:variable name="t_temp_output_string">
  629.             <xsl:if test="contains($t_input_string, $t_pattern_string) ">
  630.                 <xsl:value-of select="concat($t_output_string, substring-before($t_input_string,$t_pattern_string), $t_substitute_string) "/>
  631.             </xsl:if>
  632.             <xsl:if test="not (contains($t_input_string, $t_pattern_string)) ">
  633.                 <xsl:value-of select="$t_output_string"/>
  634.             </xsl:if>
  635.         </xsl:variable>
  636.         <xsl:if test="contains($t_input_string, $t_pattern_string) ">
  637.             <xsl:call-template name="translate_string">
  638.                 <xsl:with-param name="t_input_string" select="substring-after($t_input_string,$t_pattern_string)"/>
  639.                 <xsl:with-param name="t_pattern_string" select="$t_pattern_string"/>
  640.                 <xsl:with-param name="t_substitute_string" select="$t_substitute_string"/>
  641.                 <xsl:with-param name="t_output_string" select="$t_temp_output_string"/>
  642.             </xsl:call-template>
  643.         </xsl:if>
  644.         <xsl:if test="not (contains($t_input_string, $t_pattern_string))">
  645.             <xsl:value-of select="concat($t_temp_output_string, $t_input_string)"/>
  646.         </xsl:if>
  647.     </xsl:template>
  648.     <xsl:template name="add_hyperlink_style">
  649.         <!--this template is to add the hyperlink related style -->
  650.         <w:style w:type="character" w:styleId="Hyperlink">
  651.             <w:name w:val="Hyperlink"/>
  652.             <w:rsid w:val="006A55B0"/>
  653.             <w:rPr>
  654.                 <w:color w:val="000080"/>
  655.                 <w:u w:val="single"/>
  656.             </w:rPr>
  657.         </w:style>
  658.         <w:style w:type="character" w:styleId="FollowedHyperlink">
  659.             <w:name w:val="FollowedHyperlink"/>
  660.             <w:rsid w:val="006A55B0"/>
  661.             <w:rPr>
  662.                 <w:color w:val="800000"/>
  663.                 <w:u w:val="single"/>
  664.             </w:rPr>
  665.         </w:style>
  666.     </xsl:template>
  667.     <xsl:template match="office:annotation">
  668.         <!-- this template export writer note to word comments -->
  669.         <xsl:variable name="comments_aml_id">
  670.             <xsl:call-template name="unique_amlid_generator"/>
  671.         </xsl:variable>
  672.         <aml:annotation w:type="Word.Comment.Start">
  673.             <xsl:attribute name="aml:id">
  674.                 <xsl:value-of select="$comments_aml_id"/>
  675.             </xsl:attribute>
  676.         </aml:annotation>
  677.         <aml:annotation w:type="Word.Comment.End">
  678.             <xsl:attribute name="aml:id">
  679.                 <xsl:value-of select="$comments_aml_id"/>
  680.             </xsl:attribute>
  681.         </aml:annotation>
  682.         <!-- export aml:annotation content-->
  683.         <w:r>
  684.             <w:rPr>
  685.                 <w:rStyle w:val="CommentReference"/>
  686.             </w:rPr>
  687.             <aml:annotation aml:author="{@office:author}" aml:createdate="{@office:create-date}" w:type="Word.Comment" w:initials="{@office:author}">
  688.                 <xsl:attribute name="aml:id">
  689.                     <xsl:value-of select="$comments_aml_id"/>
  690.                 </xsl:attribute>
  691.                 <aml:content>
  692.                     <xsl:apply-templates select="text:p"/>
  693.                 </aml:content>
  694.             </aml:annotation>
  695.         </w:r>
  696.         <!-- end of  export aml:annotation content-->
  697.     </xsl:template>
  698.     <xsl:template name="unique_amlid_generator">
  699.         <!-- this template generate unique id for aml:id, ATM it only counts the office:annotation, some other elements might be added later -->
  700.         <xsl:number count="office:annotation" from="/office:document/office:body" level="any" format="1"/>
  701.     </xsl:template>
  702.     <xsl:template name="add_comments_style">
  703.         <w:style w:type="character" w:styleId="CommentReference">
  704.             <w:name w:val="annotation reference"/>
  705.             <w:basedOn w:val="DefaultParagraphFont"/>
  706.             <w:semiHidden/>
  707.             <w:rsid w:val="007770B7"/>
  708.             <w:rPr>
  709.                 <w:sz w:val="16"/>
  710.                 <w:sz-cs w:val="16"/>
  711.             </w:rPr>
  712.         </w:style>
  713.         <w:style w:type="paragraph" w:styleId="CommentText">
  714.             <w:name w:val="annotation text"/>
  715.             <w:basedOn w:val="Normal"/>
  716.             <w:semiHidden/>
  717.             <w:rsid w:val="007770B7"/>
  718.             <w:pPr>
  719.                 <w:pStyle w:val="CommentText"/>
  720.             </w:pPr>
  721.             <w:rPr>
  722.                 <w:sz w:val="20"/>
  723.                 <w:sz-cs w:val="20"/>
  724.             </w:rPr>
  725.         </w:style>
  726.         <w:style w:type="paragraph" w:styleId="CommentSubject">
  727.             <w:name w:val="annotation subject"/>
  728.             <w:basedOn w:val="CommentText"/>
  729.             <w:next w:val="CommentText"/>
  730.             <w:semiHidden/>
  731.             <w:rsid w:val="007770B7"/>
  732.             <w:pPr>
  733.                 <w:pStyle w:val="CommentSubject"/>
  734.             </w:pPr>
  735.             <w:rPr>
  736.                 <w:b/>
  737.                 <w:b-cs/>
  738.             </w:rPr>
  739.         </w:style>
  740.     </xsl:template>
  741. </xsl:stylesheet>
  742.